import 'package:floor/floor.dart';
import 'ConversationWrapper.dart';

@dao
abstract class ConversationDAO{
  @Query('SELECT * FROM Conversation ORDER BY createTime DESC')
  Future<List<ConversationWrapper>> findAllConversation();

  @Query('SELECT * FROM Conversation ORDER BY createTime DESC LIMIT 1')
  Future<ConversationWrapper?> findLast();

  @Query('SELECT * FROM Conversation WHERE id = :id')
  Future<ConversationWrapper?> findConversationById(String id);

  @insert
  Future<void> insertConversation(ConversationWrapper conversation);

  @update
  Future<void> updateConversation(ConversationWrapper conversation);

  @Query("DELETE FROM Conversation WHERE id = :id")
  Future<void> delete(String id);

  @Query("DELETE FROM Conversation")
  Future<void> deleteAllConversation();
}